package com.letfox.ad.controller.ad;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.letfox.ad.controller.BaseController;
import com.letfox.ad.service.ADAppSynthesizeService;
import com.letfox.ad.util.ADUtil;

@Controller
@RequestMapping(value = "/api")
public class ADAppController extends BaseController{
	
	@Autowired
	private ADAppSynthesizeService adAppSynthesizeService;
	
	@RequestMapping(value = "/ad_app",method=RequestMethod.POST)
	@ResponseBody
	public String saveApp(String params){
		//打印数据
		System.out.println("接收请求数据:   "+params);
		String returnJson=null;
		try {
			returnJson=adAppSynthesizeService.saveRequest(params);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			returnJson="{\"ret\":\"1\",\"msg\":\"\"}";
		}
		return returnJson;
	}	
	
	@RequestMapping(value = "/test",method=RequestMethod.GET)
	@ResponseBody
	public String test() throws Exception{
		String ip=ADUtil.getIpAddr(request);
		String mac=ADUtil.GetMac();
		String user_agent=request.getHeader("user-agent");
		String mac2=ADUtil.getMac(ip);
		String string="ip地址: "+ip+"    "+"mac地址: "+mac+"   "+"user_agent信息: "+user_agent+"   "+"mac2方法: "+mac2;
		return string;
	}	
	
	

}


                                                                